package cn.gpnu.web.servlet;

import cn.gpnu.dao.Treedao;
import cn.gpnu.dao.Userdao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/selltree_servlet")
public class selltree_servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("我被调用了");
//        int id = req.getIntHeader("id");
        int tree_id = Integer.parseInt(req.getParameter("tree_id"));
        int user_id = Integer.parseInt(req.getParameter("user_id"));
        int treeprice = Integer.parseInt(req.getParameter("treeprice"));
        System.out.println(tree_id);

        Userdao dao = new Userdao();
        dao.sell_tree(user_id,treeprice);

        Treedao treedao = new Treedao();
        treedao.sell_tree(user_id,tree_id);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
